const http = require("../api/index");
export const POSTMODEL = function (url) {
	return function(params) {
		return new Promise((resolve, reject) => {
			http.post(url, params, function (response) {
				if (response.code == 0) {
					resolve(response.data)
				} else {
          wx.showModal({
            title: '错误信息',
            content: response.msg,
            confirmText: '知道了',
            showCancel: false,
            success (res1) {
              if (res1.confirm) {
                reject(response)
              }
            }
          })
				}
			})
		})
	}
}


export const GETMODEL = function (url) {
	return function(params) {
		return new Promise((resolve, reject) => {
			http.get(url, params, function (response) {
				if (response.code == 0) {
					resolve(response.data)
				} else {
          wx.showModal({
            title: '错误信息',
            content: response.msg,
            confirmText: '知道了',
            showCancel: false,
            success (res1) {
              if (res1.confirm) {
                reject(response)
              }
            }
          })
				}
			})
		})
	}
}